Skip to main content

Full text of "SARA"

See other formats


function B= SARA(data)
C= data(:,1:size(data,2)-1);
D= data(:,size(data,2));
sCol=size(C,2); 
ConditionEntropy = condEnt([C D]);
Arr=zeros(sCol,2+size(C,1));
for attribute = 1: sCol
	Arr(attribute,1)=attribute;
	Arr(attribute,2)=condEnt([C(:,attribute) D]);
	Arr(attribute,3:size(C,1)+2)=C(:,attribute)';
end
Arr=sort(Arr,1,'descend');
Arr=Arr';
B=Arr;
loop=1;
Att=1;
E=[B(:,Att+1:size(B,2))];
while loop<=sCol
	if (ConditionEntropy==condEnt([E(3:size(C,1)+2,:) D]))
		B=E;
		Att--;
	end
Att++;
	if (Att==1)
	E=[B(:,Att+1:size(B,2))];
	elseif (Att<size(B,2))
	E=[B(:,1:Att-1) B(:,Att+1:size(B,2))];
	else
	E=[B(:,1:(size(B,2)-1))];
	end
loop++;
end
B(1:2,:)=[];




 function Z= condEnt(data)

 Z=jointEntropy(data)-Ent(data(:,1:size(data,2)-1));


		function set= toleranceClass(data,k)
		set=[];
		e=0.75;
		Cols= size(data,2);
		Rows=size(data,1);
		for i=1:Rows
		endLoop=0;
			for j=1:Cols
				if endLoop==0
					if k~=i
						if abs(data(k,j)-data(i,j))>e
							endLoop=1;	
						end
					end	
					if k==i
						endLoop=1;
					end
				end
			end
			if endLoop==0
				set=[set;i];
			end
		end



 function sum = jointEntropy(data)
 sum =0; 
 for i =1:size(data,1)
  set=0;
	tolC=toleranceClass(data(:,1:size(data,2)-1),i);
	setD=data(:,size(data,2));
	tolD=toleranceClass(setD,i);
	for i=1:length(tolC)
		for j= 1:length(tolD)
			if (tolC(i)==tolD(j))
				set=set+1;
			end
		end
	end
	if set>0
	sum=sum+log2(set/size(data,1));
	end
 end
 sum=((-1/size(data,1))*sum);


	function sum=Ent(data)

sum=0;
for i = 1:size(data,1)
	tempVal=length(toleranceClass(data,i));
	if tempVal>0
		sum=sum+log2((tempVal)/size(data,1));
	end
end
sum = (-1/(size(data,1))*sum);



Reference 

Yang, Y., Wang., and Kong, H. '2009','Self-Learning Facial Emotion Feature Selection Based on Rough Set Theory', Mathematical Problems in Engineering, Vol 2009.